package com.woniuxy.sales.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.woniuxy.sales.common.RedisConst;
import com.woniuxy.sales.model.dto.AddressRequest;
import com.woniuxy.sales.model.entity.Address;
import com.woniuxy.sales.model.entity.China;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author Administrator
* @description 针对表【address】的数据库操作Service
* @createDate 2024-11-01 10:29:07
*/
public interface AddressService extends IService<Address> {

    List<China> getAllProvince();

    @Cacheable(cacheNames = RedisConst.CITIES, key = "#root.methodName + #provinceId")
    List<China> getAllCities(Integer provinceId);

    @Cacheable(cacheNames = RedisConst.DISTRICTS, key = "#root.methodName + #cityId")
    List<China> getAllDistricts(Integer cityId);

    @Transactional
        //开启事务
    void addAddress(AddressRequest addressRequest, Integer userId);


    List<Address> query(Integer userId);

    void remove(Integer id);


    void edit(Address address);
}
